from tkinter import *
import tkinter as tk

def callback(event):
    x = event.x
    y = event.y
    textvar = "移动位置-x:{},y:{}".format(x, y)
    var.set(textvar)


root = Tk()
root.title("鼠标移动事件")
root.geometry("300x200")

x, y = 0, 0
var = StringVar()
text = "移动位置-x:{},y:{}".format(x, y)
var.set(text)

lab = Label(root, textvariable=var)
lab.pack(anchor=S, side=RIGHT, padx=10, pady=10)
root.bind("<Motion>", callback)

root.mainloop()
